<!-- src/components/Notification.vue -->
<template>
    <div v-if="visible" class="notification" :class="type">
        {{ message }}
    </div>
</template>

<script setup>
import { ref, watch } from 'vue';

const props = defineProps({
    message: {
        type: String,
        required: true
    },
    type: {
        type: String,
        default: 'success'
    },
    duration: {
        type: Number,
        default: 3000
    }
});

const visible = ref(true);

watch(visible, (newValue) => {
    if (newValue) {
        setTimeout(() => {
            visible.value = false;
        }, props.duration);
    }
});
</script>

<style scoped>
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem;
    border-radius: 6px;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.notification.success {
    background-color: #28a745;
}

.notification.error {
    background-color: #dc3545;
}
</style>